<template>
	<view class="container">
		<u-navbar placeholder title="注销账号" leftIconColor="#fff" bgColor="#0a0816" :autoBack="true"></u-navbar>
		<view class="log-box pad-32">
			<view class="top font-28 color-grey">
				<u-parse :content="content"></u-parse>
			</view>
			<view>
				<view class="centerXY" @click="hanldeCheckbox">
					<view class="mar-right-12 icon-box centerXY">
						<u-icon v-if="checkbox" size="16" color="#5347FE" name="checkbox-mark"></u-icon>
					</view>
					<view class="font-24 color-grey">我已阅读并知晓，愿意承担注销账户带来的后果。</view>
				</view>
				<u-button :customStyle="{border: 0}" :disabled="!checkbox" @click="isPopup = true" class="button mar-top-40">确认注销</u-button>
			</view>
		</view>
		<my-popup content="您确定注销当前账号吗？" :show="isPopup" @cancel="isPopup = false" @confirm="hanldeConfirm"></my-popup>
	</view>
</template>

<script>
	// 接口地址
	import {
		configIndex,
		userOff
	} from '@/config/api.js'
	export default {
		data() {
			return {
				// 富文本
				content: '',
				// 阅读完成
				checkbox: false,
				// 二次确认
				isPopup: false
			}
		},
		onLoad() {
			this.getData();
		},
		methods: {
			// 切换状态
			hanldeCheckbox() {
				this.checkbox = !this.checkbox;
			},
			// 点击注销
			hanldeConfirm() {
				userOff().then(res => {
					this.isPopup =false;
					uni.$u.toast(res.msg);
					setTimeout(()=>{
						uni.navigateBack();
					},800)
				})
			},
			// 获取注销内容
			getData() {
				configIndex({
					code_arr: ['log_off']
				}).then(res => {
					this.content = res.data.log_off;
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		min-height: 100vh;

		::v-deep .u-navbar__content {
			// background-image: url('../../static/image/my-bg.png');
			background-size: cover;
			background-repeat: no-repeat;
			background-color: #f5f5f5;
		}
	}

	.log-box {
		display: flex;
		flex-direction: column;
		height: 90vh;

		.top {
			flex-grow: 1;
		}

		.icon-box {
			width: 30rpx;
			flex-shrink: 0;
			height: 30rpx;
			border: 1rpx solid #c8c9cc;
			border-radius: 50%;
		}

		.button {
			background: $uni-bg-theme;
			box-shadow: 0 10px 15px rgba(223, 0, 7, .1);
			height: 96rpx;
			color: white;
			text-align: center;
			line-height: 96rpx;
			border-radius: 60rpx;
		}
	}
</style>